#include "topconn_executor.hpp"
#include "topconn_exception.hpp"
#include "topconn_logutil.hpp"
#include "topconn_string.hpp"

namespace topconn
{
    Executor::Executor(const string& protocalType)
        : m_connector(nullptr)
    {
        m_protocal_name = protocalType;
        topconn_string::to_upper(m_protocal_name);
    }

    Executor::~Executor()
    {
    }

    const string& Executor::getProtocalType()
    {
        return m_protocal_name;
    };

    ConnectorPtr_t   Executor::getConnector()
    {
        return m_connector;
    };

    int Executor::sendPack(ProtocalCfg& cfg, const string& type, const string& request, string& response,const string& atx)
    {
        TLOG_DEBUG("Start applying %s communication protocol processing", getProtocalType().c_str());
        m_connector = ConnectorFactory::create(type);
        m_connector->checkElementCfgValid(cfg);
        return m_connector->executor(cfg, request, response, atx);
    }
};